#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "html_utils.h"
#include "parsing.h"


#define BLOCK_SIZE 1024


/*
void add(char * host_name, char * author, char * title, char * filename)
{
  FILE * file = stdin;
  if (file == 0) {
    printf("Unanable to open file '%s'.", filename);
    return;
  }
  CLIENT * client = client_create(host_name); header("text/html");
  struct paper_info_t paper_info;
  paper_info_create(&paper_info, author, title, filename);
  int * paper_id = paper_add_1(&paper_info, client);
  printf("Paper id: %d\n", *paper_id);

  int size;
  char buffer[BLOCK_SIZE];
  block_t block;
  error_info_t * info;
  while ((size = fread(buffer,1,BLOCK_SIZE,file)) > 0) {
    create_block(&block, *paper_id, buffer, size);
    info = add_block_1(&block, client);
    if (info->error) {
      printf("Internal error: unanable to find paper with id: %d\n", *paper_id);
      exit(1);
    }
  }
  clnt_destroy(client);
}
*/


int main()
{
  char * buffer = malloc(BLOCK_SIZE);
  struct fileupload_http_header_t html_head;
 
  //http_header_parse(&html_head);  
  strip_newlines(html_head.mime_separator);

  header("text/html");
  //http_header_dump(&html_head);
  do {
    fgets(buffer, BLOCK_SIZE, stdin);
    printf(buffer);
  } while (strncmp(html_head.mime_separator, buffer, strlen(html_head.mime_separator)) != 0);
 
  free(buffer);
  return 0;
}
